import http from "@/http/index"

// 获取用户列表
export const ApiUserList = (params: IUserParams): IRES<IUserList> => http.get('/admin/list', { params })

// 修改帐号状态
export const ApiUpdateStatus = (id: number, status: number): IRES<any> => http.post(`/admin/updateStatus/${id}?status=${status}`);

// 用户注册
export const ApiUserRegister = (params: IList): IRES<IList> => http.post('/admin/register', params)

// 获取指定用户信息
export const ApiGetUserInfo = (id: number): IRES<IList> => http.get(`/admin/${id}`)

// 修改指定用户信息
export const ApiUserUpdate = (params: IList): IRES<number> => http.post(`/admin/update/${params.id}`, params)

// 获取所有角色
export const ApiGetAllUserList = (): IRES<IAllUserList[]> => http.get("/role/listAll")

// 获取指定用户的角色
export const ApiGetUserRole = (adminId: number): IRES<IAllUserList[]> => http.get(`/admin/role/${adminId}`)

// 给用户分配角色
export const ApiSetRole = (id: number, roles: number[]): IRES<any> => http.post(`/admin/role/update?adminId=${id}&roleIds=${roles.join(',')}`)

// 根据角色名称分页获取角色列表
export const ApiRoleList = (params: IUserParams): IRES<IUserTable<IRoleListData>> => http.get('/role/list', { params })

// 添加角色
export const ApiRoleCreate = (params: IRoleListData): IRES<any> => http.post('/role/create', params)

// 修改角色状态
export const ApiRoleUpdateStatus = (id: number, status: number): IRES<number> => http.post(`/role/updateStatus/${id}?status=${status}`)

// 修改角色
export const ApiRoleUpdateInfo = (params: IRoleListData): IRES<Number> => http.post(`/role/update/${params.id}`, params)

// 获取角色相关资源
export const ApiGetRoleListResource = (id: number): IRES<IRoleResource[]> => http.get(`/role/listResource/${id}`)

// 查询所有后台资源
export const ApiResourceAllList = (): IRES<IResourceAllList[]> => http.get('/resource/listAll')

// 查询所有后台资源分类
export const ApiResourceCategoryAllList = (): IRES<IResourceAllList[]> => http.get('/resourceCategory/listAll')

// 给角色分配资源
export const ApiRoleAllResource = (id: number, resourceIds: number[]): IRES<number> => http.post(`/role/allocResource?roleId=${id}&resourceIds=${resourceIds.join(',')}`)

// 获取角色相关菜单
export const ApiGetRoleListMenu = (id: number): IRES<IMenu[]> => http.get(`/role/listMenu/${id}`)

// 树形结构返回所有菜单列表
export const ApiGetMenuTreeList = (): IRES<ITreeList[]> => http.get('/menu/treeList')

// 给角色分配菜单
export const ApiAddRoleAllocMenu = (params: IRoleAllocMenu): IRES<number> => http.post(`/role/allocMenu?roleId=${params.roleId}&menuIds=${params.menuIds.join(',')}`)